home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 1.iso / HENSA / MATHS / PLPLOT / PLPLOT.ZIP / examples / C / x05c.c < prev    next >
C/C++ Source or Header  |  1994-06-30  |  2KB  |  60 lines

  1. /* $Id: x05c.c,v 1.7 1994/06/30 17:57:15 mjl Exp $
  2.  * $Log: x05c.c,v $
  3.  * Revision 1.7  1994/06/30  17:57:15  mjl
  4.  * All C example programs: made another pass to eliminate warnings when using
  5.  * gcc -Wall.  Lots of cleaning up: got rid of includes of math.h or string.h
  6.  * (now included by plplot.h), eliminated redundant casts, put in more
  7.  * uniform comments, and other minor changes.
  8.  *
  9.  * Revision 1.6  1994/03/30  07:21:48  mjl
  10.  * Changes to all C example programs: special handling for malloc re: header
  11.  * files eliminated, include of stdio.h and stdlib.h eliminated (now done
  12.  * by plplot.h), include of "plplot.h" changed to <plplot.h> to enable
  13.  * simpler builds by the general user, some cleaning up also.
  14. */
  15.  
  16. /*    x05c.c
  17.  
  18.     Histogram demo.
  19. */
  20.  
  21. #include <plplot.h>
  22.  
  23. #define NPTS 2047
  24.  
  25. /*----------------------------------------------------------------------*\
  26.  * main
  27.  *
  28.  * Draws a histogram from sample data.
  29. \*----------------------------------------------------------------------*/
  30.  
  31. int
  32. main(int argc, char *argv[])
  33. {
  34.     int i;
  35.     PLFLT data[NPTS], delta;
  36.  
  37. /* Parse and process command line arguments */
  38.  
  39.     (void) plParseInternalOpts(&argc, argv, PL_PARSE_FULL);
  40.  
  41. /* Initialize plplot */
  42.  
  43.     plinit();
  44.  
  45. /* Fill up data points */
  46.  
  47.     delta = 2.0 * 3.141592654 / (double) NPTS;
  48.     for (i = 0; i < NPTS; i++)
  49.     data[i] = sin(i * delta);
  50.  
  51.     plcol(1);
  52.     plhist(NPTS, data, -1.1, 1.1, 44, 0);
  53.     plcol(2);
  54.     pllab("#frValue", "#frFrequency",
  55.       "#frPLplot Example 5 - Probability function of Oscillator");
  56.  
  57.     plend();
  58.     exit(0);
  59. }
  60.